<?php
namespace app\urlrule;

use app\module\BaseModule;
use yii\base\BootstrapInterface;
use app\system\enums\ModuleGroupEnmu;
use app\base\classes\Hook;

class Module extends BaseModule implements BootstrapInterface
{

    const EVENT_URLRULE_PREFIX_ENTITY = "EVENT_URLRULE_PREFIX_ENTITY";

    public function init()
    {
        parent::init();
    }

    public function bootstrap($app)
    {
        Hook::on(\app\system\Module::EVENT_SYSTEM_GROUPNAV, [
            $this,
            "onSetGroupNav"
        ]);
    }

    /**
     *
     * @param \app\base\helpers\Event $event            
     */
    public function onSetGroupNav($event)
    {
        $item = [
            'label' => "路由规则",
            'icon' => "fa-signal",
            'url' => [
                "/$this->id/default/index"
            ]
        ];
        
        $event->parameters->set(ModuleGroupEnmu::STRUCTURE, [
            $item
        ]);
    }
}
